﻿using Domain.Entity;
using DtoFw.Enum;
using Repository.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Util;

namespace Repository
{
    public class MainSerialNumberRepository : BaseRepository<MainNumberEntity>
    {
        private readonly SnowFlakeGenerator worker;
        public MainSerialNumberRepository(SnowFlakeGenerator snowFlakeGenerator) : base(snowFlakeGenerator)
        {
            this.worker = snowFlakeGenerator;
        }
        /// <summary>
        /// 获取编号对象
        /// </summary>
        /// <param name="AreCode"></param>
        /// <param name="NumberTypeCode"></param>
        /// <returns></returns>
        public MainNumberEntity GetNumberEntity(long organId, EnumSystemNumber numberCode)
        {
            var sql = @"SELECT t2.* 
                          FROM system_number t2 
                          where t2.IsDeleted=0 AND `OrganId`="+ organId + " and t2.NumberCode='" + numberCode + "'";
            return base.GetDb().SqlQueryable<MainNumberEntity>(sql)?.First();
        }
    }
}
